package com.qf.service;

import com.qf.mapper.UserMapper;
import com.qf.pojo.SysUsers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * @author Wy
 * @version V1.0
 * @Project MavenDemo
 * @Package com.qf.service
 * @Description:
 * @Date 2022/6/13 21:09
 */
@Service
public class UserServiceImpl implements UserService {


    @Autowired
    private UserMapper userMapper;

    @Override
    public List<SysUsers> findUserAll() {
        List<SysUsers> userall = userMapper.findUserall();
        return userall;
    }

    @Override
    public SysUsers findUserByName(String username) {
        SysUsers userByName = userMapper.findUserByName(username);
        return userByName;
    }

    @Override
    public Set<String> findRolesByUid(int uid) {
        List<String> rolesByUid = userMapper.findRolesByUid(uid);
        Set<String> roleSet = new HashSet<>();
        if(rolesByUid!=null){
            for (String str:rolesByUid){
                roleSet.add(str);
            }
        }

        return roleSet;
    }

    @Override
    public Set<String> findPermByuid(int uid) {
        List<String> permByUid = userMapper.findPermByUid(uid);
        Set<String> objects = new HashSet<>();
        if(permByUid!=null){
            for (String str:permByUid){
                objects.add(str);
            }
        }
        return objects;
    }


}
